'use strict';

const Service = require('egg').Service;

class DishService extends Service {
  async getDish(rid,page,size) {
    try{
      const result = await this.app.mysql.query('SELECT dish.* from restaurant_dish \
      INNER JOIN dish ON restaurant_dish.did = dish.id \
      WHERE restaurant_dish.rid = ? AND dish.selling = 1 \
      ORDER BY dish.created DESC LIMIT ?,?',[rid,(page-1)*size,parseInt(size)]);
        this.ctx.code = 200;
        return result;
    }catch(err){
        this.ctx.code = 301;
        return err.message;
    }
  }
}

module.exports = DishService;
